'''
Created on Aug 7, 2009

@author: mkiyer
'''

from veggie.app.alignment.bowtie import Bowtie
from optparse import OptionParser
import sys
import logging

if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG)

    optionparser = OptionParser("usage: %prog [options] fastq")
    optionparser.add_option("--mode", dest="mode",
                            default="single-best",
                            help="alignment mode: single-best,"
                            "multi,paired-end [default: %default]")
    optionparser.add_option("--quals", dest="quals",
                            default="solexa-quals",
                            help="format of quality scores: solexa-quals,"
                            "phred33-quals, solexa1.3-quals, [default: %default]")
    optionparser.add_option("-p", dest="processors", type="int",
                            default=2,
                            help="# of processors to use for mapping [default: %default]")
    optionparser.add_option("--genome", dest="genome",
                            default="hg18",
                            help="indexes to use for mapping: "
                                 "hg18, viruses, [default: %default]")
    (options, args) = optionparser.parse_args()
        
    # options
    bowtie_options = {'-p': options.processors,
                      '--' + options.quals: None}
    # create the app controllers
    bowtie_app = Bowtie(options=bowtie_options)
    # run on test data
    if options.mode == "single-best":
        bowtie_app.run_single_best(args[0], genome=options.genome)
    elif options.mode == "multi":
        bowtie_app.run_multi(args[0], genome=options.genome)
    elif options.mode == "paired-end":
        bowtie_app.run_paired_end(args[0], args[1], genome=options.genome)